package middlewares

import (
	"errors"
	"github.com/gin-gonic/gin"
	"wskyygyso/api/pkg/response"
)

func ForceUa() gin.HandlerFunc {
	return func(context *gin.Context) {
		if len(context.Request.Header["User-Agent"]) == 0 {
			response.BadRequest(context, errors.New("User-Agent 标头未找到"), "请求必须附带 User-Agent 标头")
			return
		}
		context.Next()
	}
}
